package zw_901_1000.zw_976_三角形的最大周长;

import java.util.Arrays;

class Solution {
    public static void main(String[] args) {
        int[] nums = {3, 2, 3, 4};
        int len = largestPerimeter(nums);
        System.out.println(len);

    }

    public static int largestPerimeter(int[] nums) {
        Arrays.sort(nums);
        for (int i = nums.length - 1; i >= 2; --i) {
            if (nums[i - 2] + nums[i - 1] > nums[i]) {
                return nums[i - 2] + nums[i - 1] + nums[i];
            }
        }
        return 0;
    }
}
